﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace Sprout.Schedule.Web.Exceptions
{
    /// <summary>
    /// 异常处理
    /// </summary>
    public class WException : Exception
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public StatusCodeEnum StatusCode { get; }

        /// <summary>
        /// 消息
        /// </summary>
        public override string Message { get; }
        /// <summary>
        /// 返回值状态码
        /// </summary>
        public HttpStatusCode HttpStatusCode { get; }

        /// <summary>
        /// 内部异常
        /// </summary>
        /// <param name="message">错误消息</param>
        public WException(string message)
        {
            this.StatusCode = StatusCodeEnum.Error;
            this.Message = message;
            this.HttpStatusCode = HttpStatusCode.OK;
        }

        /// <summary>
        /// 内部异常
        /// </summary>
        /// <param name="statusCode">全局错误码</param>
        /// <param name="message">错误消息</param>
        public WException(StatusCodeEnum statusCode, string message)
        {
            this.StatusCode = statusCode;
            this.Message = message;
            this.HttpStatusCode = HttpStatusCode.OK;
        }
        /// <summary>
        /// 内部异常
        /// </summary>
        /// <param name="httpStatusCode">Http错误码</param>
        /// <param name="message">错误消息</param>
        public WException(HttpStatusCode httpStatusCode, string message)
        {
            this.Message = message;
            this.HttpStatusCode = httpStatusCode;
        }

    }
}
